<template>
	<view>
		<view class="headbox">
			<image src="../../../static/images/cc/ok.png" mode="widthFix"></image>
			<view class="names">
				<view class="name1">接单成功!</view>
				<view class="name2">订单状态已更新</view>
			</view>
		</view>
		<view class="decons">
			<view class="line"></view>
			<view class="more">
				<view class="moreOne">
					<view class="infcon">
						<view class="titles">{{order_data.serv_name}}服务</view>
						<view v-if="1==order_data.serv_enum" class="address">{{order_data.departure}}</view>
						<view class="address">{{order_data.destination}}</view>
					</view>
					<view class="km"><text>距离:</text>{{order_data.dis}}km</view>
				</view>
				<view class="usercon">
					<view>联 系 人：{{order_data.contact_name}}</view>
					<view>订单编号：{{order_data.serv_order_no}}</view>
					<view>下单时间：{{order_data.stat_1_time}}</view>
					<view>接单时间：{{order_data.stat_2_time}}</view>
				</view>
			</view>
		</view>
		<view class="botton">
			<view class="detail" @click="order_detail">订单详情</view>
			<view class="call" @click="callPhone">联系客户</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				order_id:0,
				order_data:{
					contact_name:'',
					serv_name:"",
					destination:"",
					departure:'',
					serv_order_no:'',
					stat_1_time:'',
					stat_2_time:'',
					dis:''
				},
				is_loaded:false,
			}
		},
		onLoad(option){
			console.log(option)
			this.order_id = option.order_id;
			let that = this;
			uni.getLocation({
				type: 'gcj02',
				success: function (r) {
					console.log('当前位置的经度：' + r.longitude);
					console.log('当前位置的纬度：' + r.latitude);	
					that.load_data(r.latitude,r.longitude);
				}
			});	
			
		},
		methods: {
			order_detail(){
				uni.redirectTo({
					url:"/pages/dispatch/myOrderDetail/myOrderDetail?order_id="+this.order_id
				});
			},
			callPhone(){
				uni.makePhoneCall({
					phoneNumber: this.order_data.contact_phone //仅为示例
				});
			},
			async load_data(lat,lng){
				// 获取列表
				await uni.request({
					url: '/dispatch/server/getOrderDetail',
					data: {
						order_id:this.order_id,
						lat:lat,
						lng:lng,
					},
					method:"POST",
					success: res => {
						this.order_data = res.data;
						this.is_loaded = true;
						// this.list = this.list.concat(res.data);
						console.log(res);
					},
					complete:()=>{
					}
				});	
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f7f7f7;
	}

	.headbox {
		width: 750rpx;
		height: 260rpx;
		background-color: #84BD00;
		display: flex;
		justify-content: center;
		padding-top: 40rpx;

		image {
			width: 147rpx;
			height: 109rpx;
		}

		.names {
			margin-left: 16rpx;
			margin-top: 16rpx;

			.name1 {
				font-size: 33rpx;
				color: #FFFFFF;
			}

			.name2 {
				color: rgba(255, 255, 255, 0.5);
				font-size: 26rpx;
				margin-top: 10rpx;
			}
		}
	}

	.decons {
		width: 710rpx;
		margin-left: 20rpx;
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		position: relative;
		margin-top: -60rpx;

		.line {
			width: 710rpx;
			height: 22rpx;
			border-radius: 50rpx;
			background-color: #CA281C;
		}

		.more {
			width: 666rpx;
			background: linear-gradient(180deg, #FFABA5 0%, #FFFFFF 8%);
			background-color: #FFFFFF;
			border-radius: 0 0 20rpx 20rpx;

			.moreOne {
				padding:40rpx 0;
				width: 100%;
				min-height: 192rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				border-bottom: 1px dashed #D8D8D8;

				.infcon {
					margin-left: 42rpx;
					width: 390rpx;
					.titles {
						font-size: 30rpx;
						color: #333333;
					}

					.address {
						font-size: 26rpx;
						color: #999999;
						margin-top: 8rpx;
					}
				}

				.km {
					margin-right: 42rpx;
					color: #84BD00;
					font-size: 36rpx;

					text {
						font-size: 28rpx;
					}
				}
			}

			.usercon {
				width: 582rpx;
				margin-left: 42rpx;
				padding: 36rpx 0;

				view {
					font-size: 30rpx;
					color: #666666;
					padding: 18rpx 0;
				}
			}
		}
	}

	.botton {
		width: 750rpx;
		margin-top: 62rpx;
		display: flex;
		justify-content: space-between;

		.detail {
			width: 316rpx;
			height: 82rpx;
			background-color: #FFFFFF;
			border-radius: 50rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 30rpx;
			color: #84BD00;
			box-sizing: border-box;
			border: 1px solid #84BD00;
			margin-left: 42rpx;
		}

		.call {
			width: 316rpx;
			height: 82rpx;
			background-color: #84BD00;
			border-radius: 50rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 30rpx;
			color: #FFFFFF;
			box-sizing: border-box;
			border: 1px solid #84BD00;
			margin-right: 42rpx;
		}
	}
</style>